﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using StockholmsStad.Web.UI.Class.Business;
using StockholmsStad.Web.UI.UIServiceReference;

namespace StockholmsStad.Web.UI.Test
{
    /// <summary>
    ///This is a test class for PersonTest and is intended
    ///to contain all PersonTest Unit Tests
    ///</summary>
    [TestClass]
    public class PersonTest
    {
        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext { get; set; }

        #region Additional test attributes

        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //

        #endregion

        /// <summary>
        ///A test for SurNames
        ///</summary>
        [TestMethod]
        public void SurNamesTest()
        {
            string surNames = "Svenne Gurra";
            string lastName = "Snorslev";
            var personId = new PersonalNumber("19700101", "0234");
            bool swedish = true;
            string nationality = string.Empty;
            bool sexMale = false;
            var postAddress = new Address
                                  {
                                      CoAddress = string.Empty,
                                      StreetAddress = "gatan 11",
                                      PostCode = "99999",
                                      City = "Sthlm",
                                      Country = "Sverige",
                                  };
            var target = new Person(surNames, lastName, personId, swedish, nationality, sexMale, postAddress);
            string expected = surNames;
            string actual;
            target.FirstNames = expected;
            actual = target.FirstNames;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Sex
        ///</summary>
        [TestMethod]
        public void SexTest()
        {
            string surNames = "Svenne Gurra";
            string lastName = "Snorslev";
            var personId = new PersonalNumber("19700101", "0234");
            bool swedish = true;
            string nationality = string.Empty;
            bool sexMale = false;
            var postAddress = new Address
                                  {
                                      CoAddress = string.Empty,
                                      StreetAddress = "gatan 11",
                                      PostCode = "99999",
                                      City = "Sthlm",
                                      Country = "Sverige",
                                  };
            var target = new Person(surNames, lastName, personId, swedish, nationality, sexMale, postAddress);
            Sex expected = Sex.Female;
            Sex actual;
            target.Sex = expected;
            actual = target.Sex.Value;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Sex
        ///</summary>
        [TestMethod]
        public void SexTest2()
        {
            string surNames = "Svenne Gurra";
            string lastName = "Snorslev";
            var personId = new PersonalNumber("19700101", "0234");
            bool swedish = true;
            string nationality = string.Empty;
            bool sexMale = true;
            var postAddress = new Address
                                  {
                                      CoAddress = string.Empty,
                                      StreetAddress = "gatan 11",
                                      PostCode = "99999",
                                      City = "Sthlm",
                                      Country = "Sverige",
                                  };
            var target = new Person(surNames, lastName, personId, swedish, nationality, sexMale, postAddress);
            Sex expected = Sex.Male;
            Sex actual;
            target.Sex = expected;
            actual = target.Sex.Value;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for PostAddress
        ///</summary>
        [TestMethod]
        public void PostAddressTest()
        {
            string surNames = "Svenne Gurra";
            string lastName = "Snorslev";
            var personId = new PersonalNumber("19700101", "0234");
            bool swedish = true;
            string nationality = string.Empty;
            bool sexMale = true;
            var postAddress = new Address
                                  {
                                      CoAddress = string.Empty,
                                      StreetAddress = "gatan 11",
                                      PostCode = "99999",
                                      City = "Sthlm",
                                      Country = "Sverige",
                                  };
            var target = new Person(surNames, lastName, personId, swedish, nationality, sexMale, postAddress);
            Address expected = postAddress;
            Address actual;
            target.Address = expected;
            actual = target.Address;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for PersonalNumber
        ///</summary>
        [TestMethod]
        public void PersonalNumberTest()
        {
            string surNames = "Svenne Gurra";
            string lastName = "Snorslev";
            var personId = new PersonalNumber("19700101", "0234");
            bool swedish = true;
            string nationality = string.Empty;
            bool sexMale = true;
            var postAddress = new Address
                                  {
                                      CoAddress = string.Empty,
                                      StreetAddress = "gatan 11",
                                      PostCode = "99999",
                                      City = "Sthlm",
                                      Country = "Sverige",
                                  };
            var target = new Person(surNames, lastName, personId, swedish, nationality, sexMale, postAddress);
            PersonalNumber expected = personId;
            PersonalNumber actual;
            target.PersonalNumberUI = expected;
            actual = target.PersonalNumberUI;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Nationality
        ///</summary>
        [TestMethod]
        public void NationalityTest()
        {
            string surNames = "Svenne Gurra";
            string lastName = "Snorslev";
            var personId = new PersonalNumber("19700101", "0234");
            bool swedish = true;
            string nationality = "Mullimull";
            bool sexMale = true;
            var postAddress = new Address
                                  {
                                      CoAddress = string.Empty,
                                      StreetAddress = "gatan 11",
                                      PostCode = "99999",
                                      City = "Sthlm",
                                      Country = "Sverige",
                                  };
            var target = new Person(surNames, lastName, personId, swedish, nationality, sexMale, postAddress);
            string expected = "Svenskt";
            string actual = target.Nationality;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Nationality
        ///</summary>
        [TestMethod]
        public void NationalityTest2()
        {
            string surNames = "Svenne Gurra";
            string lastName = "Snorslev";
            var personId = new PersonalNumber("19700101", "0234");
            bool swedish = false;
            string nationality = "Mullimull";
            bool sexMale = true;
            var postAddress = new Address
                                  {
                                      CoAddress = string.Empty,
                                      StreetAddress = "gatan 11",
                                      PostCode = "99999",
                                      City = "Sthlm",
                                      Country = "Sverige",
                                  };
            var target = new Person(surNames, lastName, personId, swedish, nationality, sexMale, postAddress);
            string expected = "Mullimull";
            string actual;
            target.Nationality = expected;
            actual = target.Nationality;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for LastName
        ///</summary>
        [TestMethod]
        public void LastNameTest()
        {
            string surNames = "Svenne Gurra";
            string lastName = "Snorslev";
            var personId = new PersonalNumber("19700101", "0234");
            bool swedish = false;
            string nationality = "Mullimull";
            bool sexMale = true;
            var postAddress = new Address
                                  {
                                      CoAddress = string.Empty,
                                      StreetAddress = "gatan 11",
                                      PostCode = "99999",
                                      City = "Sthlm",
                                      Country = "Sverige",
                                  };
            var target = new Person(surNames, lastName, personId, swedish, nationality, sexMale, postAddress);
            string expected = lastName;
            string actual;
            target.LastName = expected;
            actual = target.LastName;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for Person Constructor
        ///</summary>
        [TestMethod]
        public void PersonConstructorTest()
        {
            string surNames = "Svenne Gurra";
            string lastName = "Snorslev";
            var personId = new PersonalNumber("19700101", "0234");
            bool swedish = false;
            string nationality = "Mullimull";
            bool sexMale = true;
            var postAddress = new Address
                                  {
                                      CoAddress = string.Empty,
                                      StreetAddress = "gatan 11",
                                      PostCode = "99999",
                                      City = "Sthlm",
                                      Country = "Sverige",
                                  };
            var target = new Person(surNames, lastName, personId, swedish, nationality, sexMale, postAddress);
            Assert.IsNotNull(target);
        }
    }
}